package root.ontology.eventmembers;

import root.Context;
import root.ontology.events.Event;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

// Anything which exists. Probably Event should be an Instance as well.
public class Instance extends EventMember {
  public int id = 0;
  public final Context context = new Context();
  public final Hashtable<String, Instance> attributes = new Hashtable<>();
  public final List<Event> events = new ArrayList<>();

  boolean correspondTo(Instance constraint) {
    for (Event constraintEvent : constraint.events) {
      boolean satisfied = false;
      for (Event event : events) {
        if (event.correspondTo(constraintEvent)) {
          satisfied = true;
          break;
        }
      }
      if (!satisfied) {
        return false;
      }
    }
    return true;
  }
}
